<?php
require_once IMMOPHP_ROOT_PATH.'plugins/Contact/lang/fr.php';
require_once IMMOPHP_ROOT_PATH.'plugins/Contact/inc/Contact.class.php';
$template->set_filenames(array('index' => 'plugins/Contact/template/index.tpl'));
if(isset($_GET['delete'])) Contact::Delete($_GET['contact']);
$Query = "SELECT * FROM immo_contact ORDER BY date";
$pager = new PS_Pagination($db->open_link, $Query, $db, 40, 10, '');
$Sql = $pager->paginate();
$Res = $db->sql_nbresultat($Sql);
if($Res == 0) SuccesAffiche($lang['Pas_de_contact_dans_la_base'], 'index.php',3);
while($Contact = $db->sql_fetchobject($Sql))
{
    $action = '<a href="plugins.php?plugins=Contact&amp;p=view&amp;contact='.$Contact->id.'"><img src="plugins/Contact/images/folder.png" style="height:20px; width:20px; border:none;"/></a>';
    if($Session->check_admin())
    {
        $action .= '&nbsp;&nbsp;&nbsp;<a href="javascript:delcontact(\'' . $Contact->id . '\');" title=""><img src="plugins/Contact/images/delete.png" style="height:20px; width:20px; border:none;"/></a>';
    }
	$template->assign_block_vars('contact', array(
	'V_ID'	=>	$Contact->id,
	'V_PERSONNE'	=>	$Contact->nom . ' ' . $Contact->prenom,
	'V_SUJET'	=>	$Contact->sujet,
	'V_AGENCE'	=>	get_agence($Contact->agence),
	'V_DATE'	=>	date('d/m/Y', $Contact->date),
    'V_ACTION'  =>  $action,
	));
}

$template->assign_vars(array(
'L_CONTACT' =>  $lang['Contact'],
'L_NOM' =>  $lang['Nom'],
'L_AGENCE'  =>  $lang['Agence'],
'L_ACTION'  =>  $lang['Action'],
'L_DATE'    =>  $lang['Date'],
'L_SUJET'   =>  $lang['Sujet'],
'L_PERSONNE'    =>  $lang['Personne'],
'L_CONFIRM_SUPPRESSION_CONTACT'  =>  $lang['Confirmation_supression_contact'],
'V_PAGINATION'  =>  $pager->renderFullNav(),
));
$template->display('index');
?>